from fastapi.responses import JSONResponse


class AppException(Exception):
    def __init__(self, code: int, message: str):
        self.code = code
        self.message = message

    def to_response(self):
        return JSONResponse(
            status_code=self.code,
            content={"code": self.code, "message": self.message},
            headers={
                "Access-Control-Allow-Origin": "http://localhost:5173",
                "Access-Control-Allow-Credentials": "true"
            }
        )

